//
//  AFHttpTool.h
//  THHuaLv
//
//  Created by TianHe_Wsk on 15/5/21.
//  Copyright (c) 2015年 TH_wsk. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"
/**
 要使用常规的AFN网络访问
 
 1. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
 
 所有的网络请求,均有manager发起
 
 2. 需要注意的是,默认提交请求的数据是二进制的,返回格式是JSON
 
 1> 如果提交数据是JSON的,需要将请求格式设置为AFJSONRequestSerializer
 2> 如果返回格式不是JSON的,
 
 3. 请求格式
 
 AFHTTPRequestSerializer            二进制格式
 AFJSONRequestSerializer            JSON
 AFPropertyListRequestSerializer    PList(是一种特殊的XML,解析起来相对容易)
 
 4. 返回格式
 
 AFHTTPResponseSerializer           二进制格式
 AFJSONResponseSerializer           JSON
 AFXMLParserResponseSerializer      XML,只能返回XMLParser,还需要自己通过代理方法解析
 AFXMLDocumentResponseSerializer (Mac OS X)
 AFPropertyListResponseSerializer   PList
 AFImageResponseSerializer          Image
 AFCompoundResponseSerializer       组合
 */

@interface AFHttpTool : NSObject

/**检测网路状态**/
+(void)netWorkStatussuccess:(void (^)(int responseObject))success;


#pragma TH Http


/**
 *get 获取数据 返回json格式
 */
+(void)getJsonDatawithUrl:(NSString *)url    success:(void (^)(id responseObject))success fail:(void (^)(id responseObject,NSError*error))fail;


/**
 *post 提交请求到服务器 返回 json  
 */
+ (void)postJsonDatawithUrl:(NSString *)url     parameters:(id)parameters   success:(void (^)(id responseObject))success fail:(void (^)(id responseObject,NSError*error))fail;

// html5的地址
+ (NSString *)html5URLWithInterfaceStr:(NSString *)interfaceStr parametersDic:(id)parameters;
 
/**
 *post 提交附件 
 */
+(void)postFilewithUrl:(NSString *)url   parameters:(id)parameters  file:(NSMutableArray*)filePaths   success:(void (^)(id responseObject))success  progress:(void (^)(NSProgress * uploadProgress))progress fail:(void (^)(id responseObject,NSError*error))fail;
/**
 * 附件取数据下载
 */
+ (void)fileDownloadWithUrl:(NSString*)urlStr  path:(NSString *)strpath success:(void (^)(id responseObject))success;

/**
 * 附件 下载
 */
+ (void)fileDownloadWithUrl:(NSString*)urlStr  path:(NSString *)strpath success:(void (^)(id responseObject,BOOL ishave ))success fail:(void (^)(id responseObject,NSError*error))fail;

/**
 文件下载
 @param urlStr  下载地址
 @param strpath 下载后文件保存路径
 @param success 下载成功后回调
 @param fail    下载失败后回调
 */
+ (void)downloadFileWithURL:(NSString *)urlStr path:(NSString *)strpath success:(void (^)(id responseObject))success fail:(void (^)(id responseObject,NSError*error))fail;


+(void)postJsonDatawithUrl:(NSString *)url success:(void (^)(id responseObject))success fail:(void (^)(id responseObject,NSError*error))fail;

/**
 读取服务器上TXT文本内容
 */
//@param URLStr  文本地址
//@param success 请求成功回调
//@param fail    请求失败回调
+ (NSURLSessionTask *)getStringFromTxtFileURLString:(NSString *)URLStr completion:(void (^)(NSString *resultString,NSError *error))completion;

@end
